#include <Arduino.h>

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  for (int i = 0; i < 256; i++)
  {
    // DAC转换，依次往26号引脚输出线性递增的电压
    dacWrite(26, i);
    // 理论电压
    int dacVolts = 3.3 / 256.0 * i * 1000;

    // ADC转换
    // Serial.printf("%d, %d, 电压(mV)：理论:%.0f, 实际:%d\n", i, dacVolts, analogRead(34), analogReadMilliVolts(34));
    Serial.printf("%d, %d, %d, %d\n", i, analogRead(34), dacVolts, analogReadMilliVolts(34));

    delay(10);
  }
}